<?php


namespace app\api\model;


use think\Model;

class Order extends Model
{
    protected $name = 'merchant_order';
    private static $instance = [];

    public static function getInstance()
    {
        if (!(self::$instance instanceof self)) {
            self::$instance = new self();
        }
        return self::$instance;
    }

    /**
     * 单个查找
     */
    public function info(array $where, $field, $order = ['id' => 'asc'])
    {
        return $this->where($where)->field($field)->order($order)->findOrEmpty()->toArray();
    }


    /**
     * 单个更新
     */
    public function up(array $data, $where, array $allow)
    {
        return self::update($data, $where, $allow)->toArray();
    }

    /**
     * 新增
     * @param array $data
     * @param $allow
     * @return array
     * @throws BaseException
     */
    public function add(array $data, $allow = [])
    {
        return $this->create($data, $allow)->toArray();
    }

}